<!-- ***********************RSS Transfromation Stylesheet for Google Search Appliance Results ******************************

Author : Víctor Álvarez
support email: valvarez at sitesa dot com
Organization: SITESA  www.sitesa.com
Date: December, 2006
License: Apache 2.0 License

Installation: Add this XSLT to a Google Search Appliance Transformation to obtain GSA results on RSS-formed format.

***********************************************************************************************************************************************-->




<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">

  <xsl:output method="xml" omit-xml-declaration="yes" indent="yes" media-type="text/html"/>

<!-- choose version for rss : 0.91, 0.92, 2.0 -->
<xsl:variable name="RSSVERSION">2.0</xsl:variable>


<!-- *** search_url *** -->
<xsl:variable name="base_url">http://mycorp.com/search?</xsl:variable>



 
<!-- *** search_url *** -->
<xsl:variable name="search_url">
  <xsl:for-each select="/GSP/PARAM[((@name != 'start') and (@name != 'ip'))]">
    <xsl:value-of select="@name"/><xsl:text>=</xsl:text>
    <xsl:value-of select="@original_value"/>
    <xsl:if test="position() != last()">
      <xsl:text disable-output-escaping="yes">&amp;</xsl:text>
    </xsl:if>
  </xsl:for-each>
</xsl:variable>




<!-- ***************************************************RENDER THE GSA RSS******************************-->

  <xsl:template match="/">
  <rss version="{$RSSVERSION}">
    <channel>
    
    
    <title>Search Results for : <xsl:value-of select="/GSP/Q"/></title>
      <link><xsl:value-of select="concat($base_url,$search_url)"/></link>
      <description>
      Results <strong><xsl:value-of select="GSP/RES/@SN"/></strong> - <strong><xsl:value-of select="/GSP/RES/@EN"/></strong> of about <strong><xsl:value-of select="/GSP/RES/M"/></strong> for<strong><xsl:text> </xsl:text> <xsl:value-of select="GSP/Q"/></strong>
	</description>
      <generator>Google Search Appliance</generator>
      <language>en-en</language>
      <pubDate></pubDate>
      <lastBuildDate></lastBuildDate>
    
    <xsl:apply-templates select="/GSP" />
    </channel>
  </rss>
  </xsl:template>


<!-- ***************************************************RENDER THE RESULTS******************************-->
  <xsl:template match="/GSP">
    

        <xsl:apply-templates select="/GSP/RES/R"/>
  </xsl:template>






<!--  ******************************************RENDER RESULTS LIST*******************************************-->
 
  <xsl:template match="RES/R">
  
  
  <item>
    <title><xsl:value-of select="T"/></title>
    <link><xsl:value-of select="U"/></link>
    <description><xsl:value-of select="S"/></description>
    <lang><xsl:value-of select="LANG"/></lang>
    <pubDate></pubDate>
    <guid><xsl:value-of select="U"/></guid>

  	</item>
  </xsl:template>


   </xsl:stylesheet>
